#-*- coding:utf8 -*-
import sys
import faker
from selenium import webdriver

class Spider():

    def __init__(self):
        self.f = faker.Factory.create()
        self.driver = webdriver.PhantomJS()

    def getInfo(self, url):
        url = 'http://www.xicidaili.com/nn/'
        driver.get(url)
        country = driver.find_elements_by_xpath('//tr/td[1]')
        list_ip = driver.find_elements_by_xpath('//tr/td[2]')
        list_port = driver.find_elements_by_xpath('//tr/td[3]')
        list_area = driver.find_elements_by_xpath('//tr/td[4]')
        list_anonymous = driver.find_elements_by_xpath('//tr/td[5]')
        list_type = driver.find_elements_by_xpath('//tr/td[6]')
        list_speed = driver.find_elements_by_xpath('//tr/td[7]')
        list_connect_time = driver.find_elements_by_xpath('//tr/td[8]')
        list_expire_time = driver.find_elements_by_xpath('//tr/td[9]')
        list_authen_time = driver.find_elements_by_xpath('//tr/td[10]')
        for index in xrange(len(list_ip)):
            ip =list_ip[index].text
            port = list_port[index].text
            area = list_area[index].text
            is_anonymous = list_anonymous[index].text
            connect_type = list_type[index].text
            speed = list_speed[index].text
            connect_time = list_connect_time[index].text
            expire_time = list_expire_time[index].text
            authen_time = list_authen_time[index].text
            print ip, port, area, is_anonymous, connect_type, expire_time, authen_time

if __name__ == '__main__':
